#include <SFML/Graphics.hpp>
#include "resourceManager.h"
#include <iostream>
using namespace std;

resourceManager::resourceManager()
{
}

resourceManager::~resourceManager()
{
	for(map<string, sf::Texture*>::iterator ii=textures.begin(); ii!=textures.end(); ++ii)
		delete ((*ii).second);
}

void resourceManager::addTexture(string p_reference, string p_filename)
{
	sf::Texture* image = new sf::Texture();

	if (loadTexture(image, p_filename))
		textures[p_reference] = image;
}

bool resourceManager::loadTexture(sf::Texture* image, string p_filename)
{
	if (!image->loadFromFile(p_filename))
		return false;

	image->setSmooth(false);

	return true;
}

sf::Texture* resourceManager::getTexture(string p_reference)
{
	return textures[p_reference];
}